Skip to content

hash: keyed functions set arm64's DIT around each call - #11

Merged
pinhopro merged 27 commits into
mainfrom
hash/dit
Nov 22, 2026
Merged

pinhopro merged 27 commits into
mainfrom
hash/dit

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

Every public function of webcpp::hash one of whose inputs is a key, a password or a key derivation's secret input now runs with arm64's DIT set, on the thread that computes it, and returns with the thread's DIT as it found it (proposals: libraries/hash/openspec/changes/data-independent-timing).

  • detail/timing.hpp: hash's own copy of webcpp::crypto's guard (crypto depends on hash), with an engaged flag for the keyed modes of a digest; a std::source_location only where a test defines the seam.
  • Guarded: mac, hkdf_extract, hkdf_expand, hkdf, pbkdf2, kbkdf, sskdf, x963kdf, blake2b_subkey, argon2id, argon2, scrypt, bcrypt, bcrypt_verify, bcrypt_pbkdf on every backend, Botan's included; keyed BLAKE2b (digest_of, hasher) and blake3's keyed modes by their arguments. Unkeyed hashing and Boost.Hash2's aliases are not guarded (design D2, D3).
  • Tests: the guard's own (timing, timing_threads, timing_unseamed), DIT observed set during the computation (timing_during, timing_during_async), one coverage test per backend driven by doc/capabilities.json (keyed cells enter their own guard first, unkeyed digests none), the asynchronous forms on the computing thread (timing_async, timing_async_botan), Botan's exception path inside a guard (timing_botan_failure).
  • bench/timing.cpp and collect.py --timing: the guard's cost from a release build, marked provisional for the final quiet measurement pass; the pages, the changelog source and AGENTS.md.
  • Also: a reference (MrDocs) that includes hash reads only the backends its build links, and the OpenSSL-on-Emscripten refusal never stops a reference; a deterministic async_heavy cancellation case; MSVC C4459 and clang-tidy fixes in the tests.

Verified locally: native clang and gcc-15, wasip2, wasip3, Emscripten (full hash lanes), an arm64 Linux container with HWCAP_DIT, the macOS and Linux lints, MSVC 14.3 and 14.5 (only the documented Wine Boost.JSON stop on seven no-exceptions builds).

R added 27 commits November 22, 2026 07:16
…s the thread's state, hash's own copy of crypto's with an engaged flag
…rt from the other derivations, and blake3's move named as its copy
…so that GCC 15 at release reads no uninitialized phase in it
…oves every keyed cell enters its own timing guard and every unkeyed one none
… refused call asserts the error of the guard that refuses it
… computes, the pool's for a heavy function and the caller's for a cheap one
…, bcrypt_verify among the password hashes, and collect.py dates every measurement in UTC and replaces data it cannot keep
… hkdf, pbkdf2, mac and async_pbkdf2 compute, through a Hash2-form probe under their hmac
…state and 1,928 of the blake3 class on 64-bit targets
…t set DIT itself, and take whether BLAKE2b takes a key from the table, the engine checked against it
…s backend_failure and leaves DIT as found, from clear and from set
…> as SipHash with DIT, and the section names timing_during and the coverage tests' pass from DIT set
…ries the seam and which the timing tests and the coverage support include
…e Botan twin, so clang-tidy finds no unused template
…, test_password, test_info and test_input, which no parameter of the library hides (MSVC C4459 at /WX)
… its first round until the emit, so that at least one call is aborted whatever the scheduler does
…stexpr lambda, which fits a line and needs no trailing comma either way
…d links, and the refusal of OpenSSL on Emscripten never stops a reference

config.hpp's __MRDOCS__ block defined every WEBCPP_HASH_HAS_<NAME>, so that hash's own reference
documents each. The reference of another library that includes hash (trystero's, read for
Emscripten's target) then met the refusal of OpenSSL on Emscripten and BLAKE3's header, which its
build does not link. Each definition now sits between push_macro and pop_macro, which keep the
build's definition or its absence; hash's doc/Jamfile links every library, so its reference is
unchanged but for line numbers. The refusal is guarded by !defined(__MRDOCS__).
@pinhopro
pinhopro merged commit 3af42a2 into main Nov 22, 2026
1 of 3 checks passed
@pinhopro
pinhopro deleted the hash/dit branch November 22, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant